import 'package:meta/meta.dart';
// import 'package:redux/redux.dart';

@immutable
class PushServiceState {
  String regId;
  List tags;

  PushServiceState({this.tags, this.regId});
}

/// 定义操作该State的全部Action
enum PushServiceActions { setTags, addTags, deleteTags, cleanTags, setAlias, deleteAlias, setRegId }

class PushServiceAction {
  final PushServiceActions type;
  PushServiceAction({this.type});
}

class SetTagsAction extends PushServiceAction {
  final List tags;

  SetTagsAction({this.tags}) : super(type: PushServiceActions.setTags);
}
class SetRegIdAction extends PushServiceAction {
  final String regId;

  SetRegIdAction({this.regId}) : super(type: PushServiceActions.setRegId);
}

///  reducer会根据传进来的action生成新的CountState
PushServiceState pushServiceReducer(PushServiceState state, action) {
  /// 匹配Action
  if (action is SetTagsAction) {
    setTags(state, action.tags);
  }
  if (action is SetRegIdAction) {
    setRegId(state, action.regId);
  }
  return state;
}
setRegId(PushServiceState state, String regId) {
  state.regId = regId;
  print('regId:$regId');
}
setTags(PushServiceState state, List tags) {
  state.tags = tags;
  print('tags:$tags');
}
